package com.angel.service.ServiceImpl;

import com.angel.bean.dto.SocketEmployeeDto;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.angel.bean.Employee;
import com.angel.mapper.EmployeeDao;
import com.angel.service.EmployeeService;


@Service
public class EmployeeServiceImpl implements EmployeeService{

    @Resource
    private EmployeeDao employeeDao;

    @Override
    public int insert(Employee employee){
        return employeeDao.insert(employee);
    }

    @Override
    public int insertSelective(Employee employee){
        return employeeDao.insertSelective(employee);
    }

    @Override
    public int insertList(List<Employee> employees){
        return employeeDao.insertList(employees);
    }

    @Override
    public int update(Employee employee){
        return employeeDao.update(employee);
    }

    @Override
    public int delete(Employee employee){
        return employeeDao.delete(employee);
    }

    @Override
    public List<Employee> findEmployee(Employee employee) {
        return employeeDao.findEmployee(employee);
    }

    @Override
    public List<Employee> searchEmployee(Employee employee) {
        return employeeDao.searchEmployee(employee);
    }

    @Override
    public Employee findOne(Employee employee) {
        List<Employee> list =this.findEmployee(employee);
        if (list==null || list.isEmpty()){
            return null;
        }
        return list.get(0);
    }

    @Override
    public Page<Employee> findEmployeeByPage(int pageNo, int pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        return employeeDao.findAllEmployeeByPage(null);
    }

    @Override
    public SocketEmployeeDto findEmployeeAndType(Employee employee) {
        return employeeDao.findEmployeeAndType(employee);
    }
}
